﻿@page "/setting"
@inherits PageComponentBase

<MCard Outlined="true"
       Rounded="@("lg")">
    <MList>
        <MListItem OnClick="()=>ShowWeatherSource=true">
            <MListItemIcon>
                <MIcon>
                    mdi-weather-cloudy
                </MIcon>
            </MListItemIcon>
            <MListItemContent>
                天气源
            </MListItemContent>
            <MListItemAction>
                <MIcon>mdi-chevron-right</MIcon>
            </MListItemAction>
        </MListItem>

        <MDivider Class="mx-3"></MDivider>

        <MListItem Href="weatherSource">
            <MListItemIcon>
                <MIcon>
                    mdi-cloud-cog-outline
                </MIcon>
            </MListItemIcon>
            <MListItemContent>
                天气源配置
            </MListItemContent>
            <MListItemAction>
                <MIcon>mdi-chevron-right</MIcon>
            </MListItemAction>
        </MListItem>

        <MDivider Class="mx-3"></MDivider>

        <MListItem OnClick="()=>ShowThemeType=true">
            <MListItemIcon>
                <MIcon>
                    mdi-weather-night
                </MIcon>
            </MListItemIcon>
            <MListItemContent>
                深色模式
            </MListItemContent>
            <MListItemAction>
                <MIcon>mdi-chevron-right</MIcon>
            </MListItemAction>
        </MListItem>

        <MDivider Class="mx-3"></MDivider>

        <MListItem OnClick="()=>ShowCodeSource=true">
            <MListItemIcon>
                <MIcon>
                    mdi-book-open-page-variant-outline
                </MIcon>
            </MListItemIcon>
            <MListItemContent>
                查看源代码
            </MListItemContent>
            <MListItemAction>
                <MIcon>mdi-chevron-right</MIcon>
            </MListItemAction>
        </MListItem>

        <MDivider Class="mx-3"></MDivider>

        <MListItem OnClick="()=>ShowAppInfo=true">
            <MListItemIcon>
                <MIcon>
                    mdi-information-outline
                </MIcon>
            </MListItemIcon>
            <MListItemContent>
                关于
            </MListItemContent>
            <MListItemAction>
                <MIcon>mdi-chevron-right</MIcon>
            </MListItemAction>
        </MListItem>

    </MList>
</MCard>

<MDialog MaxWidth="420"
         @bind-Value="ShowWeatherSource">
    <MCard Outlined="true" Rounded="@("lg")">
        <MCardTitle Class="font-weight-bold">
            天气源
            <MSpacer></MSpacer>
            <MButton Icon="true" OnClick="()=>ShowWeatherSource= false">
                <MIcon>mdi-close</MIcon>
            </MButton>
        </MCardTitle>
        <MCardText>
            <MRadioGroup Value="WeatherSourceType"
                         TValue="WeatherSourceType"
                         ValueChanged="WeatherSourceChanged"
                         Class="mt-0 pb-1"
                         OnClick="()=>ShowWeatherSource=false"
                         HideDetails="@("auto")"
                         Mandatory="true">
                @foreach (var item in WeatherSources)
                {
                    <MRadio Label="@(item.Value.Name)"
                        Class="my-2"
                        Value="@(item.Key)">
                    </MRadio>
                    <div class="ms-8 mb-2 body-2">@item.Value.Description</div>
                }
            </MRadioGroup>
        </MCardText>
    </MCard>
</MDialog>

<MDialog MaxWidth="420"
         @bind-Value="ShowThemeType">
    <MCard Outlined="true" Rounded="@("lg")">
        <MCardTitle Class="font-weight-bold">
            深色模式
            <MSpacer></MSpacer>
            <MButton Icon="true" OnClick="()=>ShowThemeType= false">
                <MIcon>mdi-close</MIcon>
            </MButton>
        </MCardTitle>
        <MCardText>
            <MRadioGroup Value="ThemeType"
                         TValue="ThemeType"
                         ValueChanged="ThemeTypeChanged"
                         Class="mt-0 pb-1"
                         OnClick="()=>ShowThemeType=false"
                         HideDetails="@("auto")"
                         Mandatory="true">
                @foreach (var item in themeTypes)
                {
                    <MRadio Label="@(item.Key)"
                        Class="my-2"
                        Value="@(item.Value)">
                    </MRadio>
                }
            </MRadioGroup>
        </MCardText>
    </MCard>
</MDialog>

<MDialog MaxWidth="420"
         @bind-Value="ShowCodeSource">
    <MCard Outlined="true" Rounded="@("lg")">
        <MCardTitle Class="font-weight-bold">
            选择源代码网站
            <MSpacer></MSpacer>
            <MButton Icon="true" OnClick="()=>ShowCodeSource=false">
                <MIcon>mdi-close</MIcon>
            </MButton>
        </MCardTitle>
        <MCardText>
            @foreach (var item in CodeSources)
            {
                <MListItem Class="px-0" OnClick="()=>ToCodeSoucre(item.Url!)">
                    <MListItemIcon>
                        <MIcon Class="list-item-icon">
                            @(item.Icon)
                        </MIcon>
                    </MListItemIcon>
                    <MListItemContent>
                        <MListItemTitle>
                            @(item.Name)
                        </MListItemTitle>
                    </MListItemContent>
                </MListItem>
            }
        </MCardText>
    </MCard>
</MDialog>

<PModal @bind-Value="ShowAppInfo"
        Title="应用信息"
        MaxWidth="420">
    <MRow>
        <MCol Cols="6">
            应用
        </MCol>
        <MCol Cols="6">
            你的天气
        </MCol>
    </MRow>
    <MRow>
        <MCol Cols="6">
            版本
        </MCol>
        <MCol Cols="6">
            @Version
        </MCol>
    </MRow>
</PModal>                 